package com.zhou.zhxy.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhou.zhxy.pojo.Admin;
import com.zhou.zhxy.service.AdminService;
import com.zhou.zhxy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * RestController  异步交互使用
 */

@RestController
@RequestMapping("/sms/adminController")
public class AdminController {

    @Autowired
    private AdminService adminService;

    /**
     * 功能：1、分页获取管理员数据
     * @param pageNo
     * @param pageSize
     * @param admin
     * @return
     */
    @GetMapping("/getAllAdmin/{pageNo}/{pageSize}")
    public Result getAllAdmin(
            @PathVariable("pageNo") Integer pageNo,
            @PathVariable("pageSize") Integer pageSize,
            Admin admin
    ){
        Page<Admin> page = new Page<>(pageNo,pageSize);
        IPage<Admin> iPage = adminService.getAdminList(page,admin);
        return Result.ok(iPage);
    }
}
